Repository navigation
Seed the uplift feature associations in make_uplift_classification_logistic - #1090
Open
aad1tyaaaaa wants to merge 1 commit into
Open
aad1tyaaaaa wants to merge 1 commit into
aad1tyaaaaa wants to merge 1 commit into
Conversation
…gistic The association pattern for each uplift feature was drawn with Python's random module, which random_seed does not seed, so two calls with the same random_seed returned different datasets. Draw it from np.random instead.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
make_uplift_classification_logisticchooses the association pattern for each uplift feature (with the defaultrandom_select_association=True) using Python'srandom.randint.random_seedonly seedsnp.random, so two calls with the samerandom_seedreturn different datasets: the*_uplift_transformedcolumns, the conversion probabilities and the outcome all change.This PR draws the index from
np.randominstead, sorandom_seedcontrols the whole dataset, and removes therandomimport, which is no longer used. Because the numpy random stream now covers this draw, a given seed produces different numbers than before; before this change those numbers were not reproducible anyway.Types of changes
Checklist
Further comments
The new test
test_make_uplift_classification_logistic_is_reproducibleintests/test_datasets.pyfails on master and passes with this change;tests/test_datasets.pypasses and black is clean. This and thenp.asscalarfix both add a test totests/test_datasets.py, so whichever is merged second may need a small rebase.I used an AI assistant (Claude Code) to help find this bug and write the fix and test. I reviewed and ran everything myself.